package com.wnxy.sddfp.system.config;

import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.RequestOriginParser;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

@Component
public class HeaderOriginParser implements RequestOriginParser {
    @Override
    public String parseOrigin(HttpServletRequest httpServletRequest) {
        String header = httpServletRequest.getHeader("origin");
        if(StringUtils.isBlank(header)){
            throw new RuntimeException("请求来源origin为空！");
        }
        return header;
    }
}